Step 3: Use WebViewPaymentViewController Directly
If you need more control over presentation, use WebViewPaymentViewController directly instead of WePaySDK.openCheckoutUrl().
Presenting the View Controller​
import WePaySDK
let webVC = WebViewPaymentViewController(checkoutUrl: checkoutUrl)
let nav = UINavigationController(rootViewController: webVC)
nav.modalPresentationStyle = .fullScreen
present(nav, animated: true)
When to Use This Approach​
| Scenario | Recommended Approach |
|---|---|
| Simple integration, default behavior | WePaySDK.openCheckoutUrl() |
| Custom navigation controller configuration | WebViewPaymentViewController directly |
| Custom presentation style (e.g., sheet, formSheet) | WebViewPaymentViewController directly |
| Need to set a delegate or observe dismissal | WebViewPaymentViewController directly |
| Embedding in a container view controller | WebViewPaymentViewController directly |
Handling Dismissal​
You can use presentationController(_:didDismiss:) or a custom delegate on the view controller to detect when the user dismisses the checkout:
import WePaySDK
class ViewController: UIViewController {
func openWePayCheckout(checkoutUrl: String) {
let webVC = WebViewPaymentViewController(checkoutUrl: checkoutUrl)
let nav = UINavigationController(rootViewController: webVC)
nav.modalPresentationStyle = .fullScreen
nav.presentationController?.delegate = self
present(nav, animated: true)
}
}
extension ViewController: UIAdaptivePresentationControllerDelegate {
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
// Checkout was dismissed — refresh order status
}
}
Next Step​
Proceed to Configuration for required Info.plist settings.